//
//  HttpRequest.h
//  RedballBar
//
//  Created by Faith on 2019/1/9.
//  Copyright © 2019 Faith. All rights reserved.
//

#import <Foundation/Foundation.h>


@interface HttpRequest : NSObject

/**
 * 获取对象实例
 */
+ (instancetype)getInstance;

/**
 *  发送GET请求
 *
 *  @param requestUrl  请求的网址字符串
 *  @param parameters 请求的参数
 *  @param success    请求成功的回调
 */
- (void)getUrl:(NSString *)requestUrl parameters:(NSDictionary *)parameters success:(void (^)(id responseObject))success;

/**
 *  发送GET请求
 *
 *  @param requestUrl  请求的网址字符串
 *  @param parameters 请求的参数
 *  @param success    请求成功的回调
 *  @param failure    请求失败的回调
 *  @param unauthorized 未授权回调
 */
- (void)getUrl:(NSString *)requestUrl parameters:(NSDictionary *)parameters success:(void (^)(id responseObject))success failure:(void (^)(NSError *error))failure;

/**
 *  发送GET请求
 *
 *  @param requestUrl  请求的网址字符串
 *  @param parameters 请求的参数
 *  @param success    请求成功的回调
 *  @param failure    请求失败的回调
 *  @param unauthorized 未授权回调
 */
- (void)getUrl:(NSString *)requestUrl parameters:(NSDictionary *)parameters success:(void (^)(id responseObject))success failure:(void (^)(NSError *error))failure unauthorized:(void (^)(void))unauthorized;

/**
 *  发送表单数据
 *
 *  @param requestUrl  请求的网址字符串
 *  @param parameters 请求的参数
 *  @param success    请求成功的回调
 */
- (void)postForm:(NSString *)requestUrl parameters:(NSDictionary *)parameters success:(void (^)(id responseObject))success;

/**
 *  发送表单数据
 *
 *  @param requestUrl  请求的网址字符串
 *  @param parameters 请求的参数
 *  @param success    请求成功的回调
 *  @param failure    请求失败的回调
 */
- (void)postForm:(NSString *)requestUrl parameters:(NSDictionary *)parameters success:(void (^)(id responseObject))success failure:(void (^)(NSError *error))failure;


/**
 *  发送表单数据
 *
 *  @param requestUrl  请求的网址字符串
 *  @param parameters 请求的参数
 *  @param success    请求成功的回调
 */
- (void)postForm:(NSString *)requestUrl parameters:(NSDictionary *)parameters loading:(NSString*)loading success:(void (^)(id responseObject))success;

/**
 *  发送表单数据
 *
 *  @param requestUrl  请求的网址字符串
 *  @param parameters 请求的参数
 *  @param success    请求成功的回调
 *  @param failure    请求失败的回调
 */
- (void)postForm:(NSString *)requestUrl parameters:(NSDictionary *)parameters loading:(NSString*)loading success:(void (^)(id responseObject))success failure:(void (^)(NSError *error))failure;

/**
 *  发送表单数据
 *
 *  @param requestUrl  请求的网址字符串
 *  @param parameters 请求的参数
 *  @param success    请求成功的回调
 *  @param failure    请求失败的回调
 *  @param unauthorized 未授权回调
 */
- (void)postForm:(NSString *)requestUrl parameters:(NSDictionary *)parameters success:(void (^)(id responseObject))success failure:(void (^)(NSError *error))failure unauthorized:(void (^)(void))unauthorized;


/**
 *  发送JSON请求
 *
 *  @param requestUrl  请求的网址字符串
 *  @param data 请求的参数
 *  @param success    请求成功的回调
 */
- (void)postJson:(NSString *)requestUrl object:(NSDictionary *)object success:(void (^)(id responseObject))success;

/**
 *  发送JSON请求
 *
 *  @param requestUrl  请求的网址字符串
 *  @param data 请求的参数
 *  @param success    请求成功的回调
 *  @param failure    请求失败的回调
 */
- (void)postJson:(NSString *)requestUrl object:(NSDictionary *)object success:(void (^)(id responseObject))success failure:(void (^)(NSError *error))failure;


/**
 *  发送JSON请求
 *
 *  @param requestUrl  请求的网址字符串
 *  @param data 请求的参数
 *  @param success    请求成功的回调
 *  @param failure    请求失败的回调
 *  @param unauthorized 未授权回调
 */
- (void)postJson:(NSString *)requestUrl object:(NSDictionary *)object success:(void (^)(id responseObject))success failure:(void (^)(NSError *error))failure unauthorized:(void (^)(void))unauthorized;

/**
 *  上传文件
 *
 *  @param requestUrl  请求的网址字符串
 *  @param name 表单名字
 *  @param data 请求的参数
 *  @param success    请求成功的回调
 */
- (void)postFile:(NSString *)requestUrl name:(NSString *)name fileName:(NSString *)fileName data:(NSData *)data success:(void (^)(id responseObject))success;

/**
 *  上传文件
 *
 *  @param requestUrl  请求的网址字符串
 *  @param name 表单名字
 *  @param data 请求的参数
 *  @param success    请求成功的回调
 *  @param failure    请求失败的回调
 */
- (void)postFile:(NSString *)requestUrl name:(NSString *)name fileName:(NSString *)fileName data:(NSData *)data success:(void (^)(id responseObject))success failure:(void (^)(NSError *error))failure;

/**
 *  上传文件
 *
 *  @param requestUrl  请求的网址字符串
 *  @param name 表单名字
 *  @param data 请求的参数
 *  @param success    请求成功的回调
 *  @param failure    请求失败的回调
 *  @param unauthorized 未授权回调
 */
- (void)postFile:(NSString *)requestUrl name:(NSString *)name fileName:(NSString *)fileName data:(NSData *)data success:(void (^)(id responseObject))success failure:(void (^)(NSError *error))failure unauthorized:(void (^)(void))unauthorized;


/**
 * 获取URL数据
 */
- (void)putUrl:(NSString *)requestUrl parameters:(NSDictionary *)parameters success:(void (^)(id))success;

/**
 * 获取URL数据
 */
- (void)putUrl:(NSString *)requestUrl parameters:(NSDictionary *)parameters success:(void (^)(id))success failure:(void (^)(NSError *))failure;

/**
 * 获取URL数据
 */
- (void)putUrl:(NSString *)requestUrl parameters:(NSDictionary *)parameters success:(void (^)(id))success failure:(void (^)(NSError *))failure unauthorized:(void (^)(void))unauthorized;


+ (NSDictionary *)processDictionary:(NSDictionary *)dictionary;

@end
